<template>
	<view class="page">
		<uni-title :title="orderInfo.orderNo" type="h2" align="center"></uni-title>
		<uni-section title="订单信息" type="line">
			<uni-list :border="false">
				<uni-list-item title="购物视频" rightText="查看" showArrow link :to="`/pages/order/video?orderId=${orderInfo.orderId}`"/>
				<uni-list-item title="联系电话" :rightText="orderInfo.customer.phoneNumber"/>
				<uni-list-item title="订单号" :rightText="orderInfo.orderId"/>
				<uni-list-item title="订单金额" :rightText="orderInfo.orderPrice"/>
				<uni-list-item title="支付状态" :rightText="orderInfo.payState == '2' ? '已支付' : '未支付'"/>
				<uni-list-item title="创建时间" :rightText="orderInfo.orderTime"/>
			</uni-list>
		</uni-section>
		<uni-section title="商品信息" type="line" v-if="orderInfo.goodsList && orderInfo.goodsList.length > 0">
			<uni-list :border="false">
				<uni-list-item
					v-for="(item, index) in orderInfo.goodsList" 
					:key="index" 
					:title="item.goodsName"
					:rightText="`${item.quantity}件 * ￥${item.sellPrice}`"
				/>
			</uni-list>
		</uni-section>
		<uni-section title="设备信息" type="line">
			<uni-list :border="false">
				<uni-list-item title="设备编号" :rightText="orderInfo.machine.machineNo"/>
				<uni-list-item title="设备名称" :rightText="orderInfo.machine.machineName"/>
				<uni-list-item title="机器号" :rightText="orderInfo.machine.machineId"/>
				<uni-list-item title="详细地址" :rightText="orderInfo.machine.machinePlace"/>
			</uni-list>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderId: "",
				orderInfo: {}
			}
		},
		
		onLoad(options) {
			this.orderId = options.orderId
			
			this.getOrderInfo()
		},
		
		methods: {
			getOrderInfo() {
				uni.showLoading({
					title: '加载中...'
				})
				uni.request({
					url: getApp().globalData.apiUrl + '/card/api/v1/orderDetail',
					data: {
						orderId: this.orderId
					},
					success: res => {
						if(res.data.success) {
							this.orderInfo = res.data.result
							uni.hideLoading()
						} else {
							uni.showToast({
								icon:'error',
								title: res.data.message
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		background-color: #fff;
	}
	
	.shop-video {
		margin: 0 25rpx;
		width: 700rpx;
	}
</style>